{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
  <title>Bootstrap 101 Template</title>
  <!-- Bootstrap -->
  <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1>你好，test！</h1>

{% csrf_token %}
用户名：<input type="text" id="username">
<button id="btn">提交</button>

</body>

<script src="{% static 'jquery.js' %}"></script>
<script src="{% static 'jquery.cookie.js' %}"></script>

<script>
  $('#btn').click(function () {

      $.ajax({
          url:'/test/',
          type:'post',
          headers:{
              "X-CSRFToken": $.cookie('csrftoken'),
          },
          data:{
              {#csrfmiddlewaretoken:$('[name=csrfmiddlewaretoken]').val(),#}
              uname:$('#username').val(),
          },
          success:function (res) {
              console.log(res)
          }

      })
  })



</script>

</html>